<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 200px;
            height: 20px;
            overflow: hidden;
            margin-top: 200px;
            margin-left: 200px;
            position: relative;
        }

        img {
            cursor: pointer;
            position: absolute;
        }

        img:nth-of-type(1) {
            top: -28px;
            left: 0;
        }

        img:nth-of-type(2) {
            top: -28px;
            left: 35px;
        }

        img:nth-of-type(3) {
            top: -28px;
            left: 70px;
        }

        img:nth-of-type(4) {
            top: -28px;
            left: 105px;
        }

        img:nth-of-type(5) {
            top: -28px;
            left: 140px;
        }
    </style>
</head>

<body>
    <div class="box">
        <img src="img/star.png" alt="">
        <img src="img/star.png" alt="">
        <img src="img/star.png" alt="">
        <img src="img/star.png" alt="">
        <img src="img/star.png" alt="">
    </div>
    <script>
        var imgs = document.querySelectorAll('img');
        for (var i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function () {
                if (this.style.top == "-28px") {
                    this.style.top = '-8px';
                } else {
                    this.style.top = "-28px";
                }
            }
        }

    </script>
</body>

</html>